<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js"></script>
    <style>
        .box {
            width: 100px;
            height: 100px;
            background-color: red;
        }

        .fs40 {
            font-size: 40px;
        }
    </style>
</head>
<body>

<div id="app">
    <div :class="class1">fs40</div>
    <div :class="class2">fs40</div>
    <!-- 数组 -->
    <div :class="class3">fs40</div>
    <!-- 三目表达式 -->
    <div :class="flag? 'box':'fs40'">fs40</div>
    <!-- 对象 -->
    <div :class='class4'>fs40</div>
    <!-- 数组内置对象 -->
    <div :class='class5'>fs40</div>
    <button @click="add">add</button>

</div>
</body>
<script>
    const vm = new Vue({
        el: '#app',
        data: {
            flag: true,
            class1: 'box',
            class2: 'box fs40',
            class3: ['box'],
            class4: {
                box: true
            },
            class5: [{box: true, fs40: true}]
        },
        methods: {
            add() {

                this.class3.push('fs40');
                this.flag = !this.flag;
            }
        }
    })
</script>

</html>